package com.business.commons.baseUtil;

import java.util.HashMap;
import java.util.Map;

public class Url2Map {

	
	private Url2Map(){
	}
	
	
	private static Url2Map instance;
	
	public static Url2Map get() {
		if(instance == null ){
			instance = new Url2Map(); 
		}
		return instance;
	}
	/**
	 * 
	 * @param string
	 * @return
	 */
	public  Map<String, String> url2map(String string) {


		Map<String, String> paraMap = null;
		try {
			if (string!=null) {
				paraMap = new HashMap<String, String>();
				String[] paras = string.split("&");
				if (null != paras && paras.length > 0) {
					for (int i = 0; i < paras.length; i++) {
						String tempStr = paras[i];
						int splitIndex = tempStr.indexOf("=");
						paraMap.put(tempStr.substring(0, splitIndex), tempStr
								.substring(splitIndex + 1, tempStr.length()));
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return paraMap;
	}
}
